package com.dingding.study.service.事件发布机制;

import com.dingding.study.mapper.UserMapper;
import com.dingding.study.service.impl.UserServiceImpl;
import com.google.common.eventbus.Subscribe;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @program: spring-learning
 * @description:
 * @author: liugongding
 * @create: 2021-09-10 11:58
 **/
public class EventListener {

    @Autowired
    private UserServiceImpl service;

    @Autowired
    private UserMapper userDao;

    @Subscribe
    public void listener(Event event){
        System.out.println("当前线程："+Thread.currentThread().getName());
        System.out.println("Subscribe 接收消息:" + event.getMessage());
        System.out.println("Subscribe 接收对象:" + event.getObject());
//        if ((Boolean) event.getObject()){
//            User user = new User();
//            user.setUsername("cnm");
//            userDao.insert(user);
//        }
    }
}
